<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.longtop.com/intelliweb" prefix="e"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>Insert title here</title>
	</head>
	<e:View id="view">
		<script type="text/javascript">SkinUtil.getSkin();</script>
		<script type="text/javascript">SkinUtil.getModuleSkin();</script>
		    
		<div id="Invisual Controls" style="min-height: 40px; background-color: LemonChiffon;" >
			<e:Dataset id="Dataset_FlowInstance" datasetDefinition="DatasetDefinition_sys.dsd" datasetRef="Dataset_FlowInstance" pageSize="10" loadDataCommand="Command_Load" allowMultiSelect="false">
				<e:Field name="instanceId" dataType="string" label="实例ID" maxLength="32" visible="false"/>
				 <e:Field name="templateId" dataType="string" label="流程模板类型" maxLength="32"  dropDown="DataDropDown_Template"/>				
				 <e:Field name="launchUserId" dataType="string" label="启动人ID" maxLength="32" />
				 <e:Field name="launchUserName" dataType="string" label="启动人" maxLength="100" />				 
				 <e:Field name="launchTime" dataType="timestamp" label="启动时间" maxLength="11" />				 
				 <e:Field name="launchOrgId" dataType="string" label="启动人机构ID" maxLength="32" visible="false"/>
				 <e:Field name="launchOrgName" dataType="string" label="启动人机构名称" maxLength="100" />
				 <e:Field name="status" dataType="string" label="流程状态" maxLength="1"  dropDown="ListDropDown_Status"/>
				 <e:Field name="nodeName" dataType="string" label="当前处理结点" maxLength="32" />
				 <e:Field name="nodeUrl" dataType="string" label="节点URL" maxLength="32" />
				 <e:Field name="viewUrl" dataType="string" label="流程URL" maxLength="32" />
			</e:Dataset>
			<e:Dataset id="Dataset_FlowTemplate" datasetDefinition="DatasetDefinition_sys.dsd" datasetRef="Dataset_FlowTemplate" pageSize="-1">
				<e:Field name="templateId" dataType="string" label="模板ID" maxLength="32" />
				 <e:Field name="templateName" dataType="string" label="模板名称" maxLength="100" />
				 <e:Field name="viewUrl" dataType="string" label="流程查看地址" maxLength="200" />
				 <e:Field name="remark" dataType="string" label="备注" maxLength="200" />
			</e:Dataset>
			
			<e:Command id="Command_Search" action="com.longtop.framework.sys.flow.web.FlowInstanceListAction" method="searchFlowInstance" submitForm="true" submitFormScope="all" validateRequired="true">
				<e:DatasetInfo name="DatasetInfo2" dataset="Dataset_FlowInstance" alwayRefreshClient="true" submitType="none"></e:DatasetInfo>
			</e:Command>
			<e:Command id="Command_Load" action="com.longtop.framework.sys.flow.web.FlowInstanceListAction" method="loadFlowInstance" submitForm="true" submitFormScope="all"  showHintInfoOnSuccess="false">
				<e:DatasetInfo name="DatasetInfo3" dataset="Dataset_FlowInstance" alwayRefreshClient="true"></e:DatasetInfo>
			</e:Command>
			
			<e:ListDropDown id="ListDropDown_Status" autoDropDown="true" fixed="true">
				<e:ListDropDownItem name="ListDropDownItem1" label="已办结" value="1" />
				<e:ListDropDownItem name="ListDropDownItem2" label="未办结" value="0" />
			</e:ListDropDown>
		
			<e:ListDropDown id="ListDropDown_Relation" autoDropDown="true" fixed="true">
				<e:ListDropDownItem name="ListDropDownItem1" label="我的待办" value="1" />
				<e:ListDropDownItem name="ListDropDownItem2" label="我的申请" value="2" />
				<e:ListDropDownItem name="ListDropDownItem3" label="我参与过" value="3" />
			</e:ListDropDown>
			
			<e:DataDropDown id="DataDropDown_Template" dataset="Dataset_FlowTemplate" visibleFields="templateName"
					codeField="templateId" textField="templateName" autoDropDown="true" fixed="true" showColumnHeader="false" >
			</e:DataDropDown>
		</div>
		
		<body>
			<e:Page id="ePage" action="com.longtop.framework.sys.flow.web.FlowInstanceListAction" style="min-height: 80px; width: 100%; height: 100%;">
				<table style="width: 100%; height: 100%;" border="0" cellpadding="0" cellspacing="0" width="100%" align="center">
					<tr>
						<td align="left" valign="top">
							<e:Panel id="Panel_Search" style="width: 285px; height: 100%" caption="查询条件" captionIcon="/images/query_win.gif" captionStyle="color:#888888" allowFold="true"  showArrowButton="false">
								<table style="text-align: left; width: 100%;" border="0" cellpadding="3" cellspacing="3" width="100%" align="center">
									<tr>
								<td width="80px" align="right">
									<e:Label id="Label_TemplateId" caption="流程类型"></e:Label>
								</td>
								<td>
									<e:Text id="Text_TemplateId" style="width:169px;" dropDown="DataDropDown_Template"></e:Text>
								</td>
							</tr>
							<tr>
								<td align="right">
									<e:Label id="Label_launchUserName" caption="流程申请人"></e:Label>
								</td>
								<td>
									<e:Text id="Text_Launcher" style="width:169px;"></e:Text>
								</td>
							</tr>
							<tr>
								<td align="right">	
									<e:Label id="Label_Relation" caption="流程关系"></e:Label>
								</td>
								<td>
									<e:Text id="Text_Relation" style="width:169px;" dropDown="ListDropDown_Relation" value="1"></e:Text>
								</td>
							</tr>
							<tr>
								<td align="right">
									<e:Label id="Label_Status" caption="流程状态"></e:Label>
								</td>
								<td>
									<e:Text id="Text_Status" style="width:169px;" dropDown="ListDropDown_Status"></e:Text>
								</td>
							</tr>
							<tr>
								<td></td>
								<td>
									<e:Button id="Button_Search" style='height: 22px; width: 70px' caption="查询"  icon="/images/query.gif" onClick="Button_Search_onClick()"></e:Button>
								</td>
							</tr>
								</table>
							</e:Panel>
						</td>
						<td valign="top" width="100%">
							<e:Panel id="Panel_Result" style="width: 100%; height: 100%" captionStyle="color:#888888" caption="查询结果列表" captionIcon="/images/list_win.gif">
								<table style="text-align: left; width: 100%;" border="0" cellpadding="3" cellspacing="3" >
									<tr>
										<td>
											<table style="text-align: left; width: 100%;" border="0" cellpadding="0" cellspacing="0">
												<tr>
													<td height="27px" width="1%">
														<e:RecordNavigator id="RecordNavigator_Instance" dataset="Dataset_FlowInstance" showNavigatorButton="false">
															<e:RecordButton id="RecordButton_ViewInstance" label="查看流程" onClick="RecordButton_ViewInstance_onClick()" icon="/images/list_win.gif" ></e:RecordButton>
															<e:RecordButton id="RecordButton_DoFlow" label="处理流程" onClick="RecordButton_DoFlow_onClick()" icon="/images/list_win.gif" ></e:RecordButton>
														</e:RecordNavigator>
													</td>
													<td align="left" width="99%"><e:PageNavigator id="PageNavigator_Template" dataset="Dataset_FlowInstance" showRecordNum="true"></e:PageNavigator></td>
												</tr>
											</table>
										</td>
									</tr>
									<tr>
										<td>
											<e:Grid id="Grid_Template" style="width: 100%; height: 100%;" showIndex="true" dataset="Dataset_FlowInstance" onClick="Grid_Template_onClick()" >
											</e:Grid>
										</td>
									</tr>
								</table>
							</e:Panel>
						</td>
					</tr>
			    </table>
			</e:Page>
		</body>
		<script type="text/javascript">
			
			//查询
			function Button_Search_onClick(){
			    Command_Search.execute();
				if($J("Text_Relation").getValue() == 1){
					$J("RecordNavigator_Instance").getRecordButtonById("RecordButton_DoFlow").setEnabled("true");
				}else {
					$J("RecordNavigator_Instance").getRecordButtonById("RecordButton_DoFlow").setEnabled("false");
				}
			}
			
			//查看流程
			function RecordButton_ViewInstance_onClick(){
				var dataset_Instance = $J("Dataset_FlowInstance");		//取得dataset
				var record = dataset_Instance.getCurrentRecord();	//取得当前record
				if(record) { 
					var instanceId = record.getString("instanceId");			//取得实例id
					var viewUrl = record.getString("viewUrl");
				
					var path = viewUrl + "?instanceId=" + instanceId;
					openTab('view_' + instanceId, '查看流程', path);
				}
			}
			
			//处理流程
			function RecordButton_DoFlow_onClick(){
				if($J("Text_Relation").getValue() != 1){
					alert("选择我的待办，才能进行流程处理操作!");
					return;
				}
			
				var dataset_Instance = $J("Dataset_FlowInstance");		//取得dataset
				var record = dataset_Instance.getCurrentRecord();	//取得当前record
				if(record) { 
					var instanceId = record.getString("instanceId");			//取得实例id
					var nodeUrl = record.getString("nodeUrl");
				
					var path = nodeUrl + "?instanceId=" + instanceId;
					openTab('do_' + instanceId, '处理流程', path);
				}
			}
		</script>
	</e:View>
</html>
